1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module adw.SwipeTracker; 26 27 private import adw.SwipeableIF; 28 private import adw.c.functions; 29 public import adw.c.types; 30 private import glib.ConstructionException; 31 private import gobject.ObjectG; 32 private import gobject.Signals; 33 private import gtk.OrientableIF; 34 private import gtk.OrientableT; 35 private import std.algorithm; 36 37 38 /** 39 * A swipe tracker used in [class@Carousel], [class@Flap] and [class@Leaflet]. 40 * 41 * The `AdwSwipeTracker` object can be used for implementing widgets with swipe 42 * gestures. It supports touch-based swipes, pointer dragging, and touchpad 43 * scrolling. 44 * 45 * The widgets will probably want to expose the [property@SwipeTracker:enabled] 46 * property. If they expect to use horizontal orientation, 47 * [property@SwipeTracker:reversed] can be used for supporting RTL text 48 * direction. 49 * 50 * Since: 1.0 51 */ 52 public class SwipeTracker : ObjectG, OrientableIF 53 { 54 /** the main Gtk struct */ 55 protected AdwSwipeTracker* adwSwipeTracker; 56 57 /** Get the main Gtk struct */ 58 public AdwSwipeTracker* getSwipeTrackerStruct(bool transferOwnership = false) 59 { 60 if (transferOwnership) 61 ownedRef = false; 62 return adwSwipeTracker; 63 } 64 65 /** the main Gtk struct as a void* */ 66 protected override void* getStruct() 67 { 68 return cast(void*)adwSwipeTracker; 69 } 70 71 /** 72 * Sets our main struct and passes it to the parent class. 73 */ 74 public this (AdwSwipeTracker* adwSwipeTracker, bool ownedRef = false) 75 { 76 this.adwSwipeTracker = adwSwipeTracker; 77 super(cast(GObject*)adwSwipeTracker, ownedRef); 78 } 79 80 // add the Orientable capabilities 81 mixin OrientableT!(AdwSwipeTracker); 82 83 84 /** */ 85 public static GType getType() 86 { 87 return adw_swipe_tracker_get_type(); 88 } 89 90 /** 91 * Creates a new `AdwSwipeTracker` for @widget. 92 * 93 * Params: 94 * swipeable = a widget to add the tracker on 95 * 96 * Returns: the newly created `AdwSwipeTracker` 97 * 98 * Since: 1.0 99 * 100 * Throws: ConstructionException GTK+ fails to create the object. 101 */ 102 public this(SwipeableIF swipeable) 103 { 104 auto __p = adw_swipe_tracker_new((swipeable is null) ? null : swipeable.getSwipeableStruct()); 105 106 if(__p is null) 107 { 108 throw new ConstructionException("null returned by new"); 109 } 110 111 this(cast(AdwSwipeTracker*) __p, true); 112 } 113 114 /** 115 * Gets whether to allow swiping for more than one snap point at a time. 116 * 117 * Returns: whether long swipes are allowed 118 * 119 * Since: 1.0 120 */ 121 public bool getAllowLongSwipes() 122 { 123 return adw_swipe_tracker_get_allow_long_swipes(adwSwipeTracker) != 0; 124 } 125 126 /** 127 * Gets whether @self can be dragged with mouse pointer. 128 * 129 * Returns: whether mouse dragging is allowed 130 * 131 * Since: 1.0 132 */ 133 public bool getAllowMouseDrag() 134 { 135 return adw_swipe_tracker_get_allow_mouse_drag(adwSwipeTracker) != 0; 136 } 137 138 /** 139 * Gets whether @self is enabled. 140 * 141 * Returns: whether @self is enabled 142 * 143 * Since: 1.0 144 */ 145 public bool getEnabled() 146 { 147 return adw_swipe_tracker_get_enabled(adwSwipeTracker) != 0; 148 } 149 150 /** 151 * Gets whether @self is reversing the swipe direction. 152 * 153 * Returns: whether the direction is reversed 154 * 155 * Since: 1.0 156 */ 157 public bool getReversed() 158 { 159 return adw_swipe_tracker_get_reversed(adwSwipeTracker) != 0; 160 } 161 162 /** 163 * Get the widget @self is attached to. 164 * 165 * Returns: the swipeable widget 166 * 167 * Since: 1.0 168 */ 169 public SwipeableIF getSwipeable() 170 { 171 auto __p = adw_swipe_tracker_get_swipeable(adwSwipeTracker); 172 173 if(__p is null) 174 { 175 return null; 176 } 177 178 return ObjectG.getDObject!(SwipeableIF)(cast(AdwSwipeable*) __p); 179 } 180 181 /** 182 * Sets whether to allow swiping for more than one snap point at a time. 183 * 184 * Params: 185 * allowLongSwipes = whether to allow long swipes 186 * 187 * Since: 1.0 188 */ 189 public void setAllowLongSwipes(bool allowLongSwipes) 190 { 191 adw_swipe_tracker_set_allow_long_swipes(adwSwipeTracker, allowLongSwipes); 192 } 193 194 /** 195 * Sets whether @self can be dragged with mouse pointer. 196 * 197 * Params: 198 * allowMouseDrag = whether to allow mouse dragging 199 * 200 * Since: 1.0 201 */ 202 public void setAllowMouseDrag(bool allowMouseDrag) 203 { 204 adw_swipe_tracker_set_allow_mouse_drag(adwSwipeTracker, allowMouseDrag); 205 } 206 207 /** 208 * Sets whether @self is enabled. 209 * 210 * Params: 211 * enabled = whether @self is enabled 212 * 213 * Since: 1.0 214 */ 215 public void setEnabled(bool enabled) 216 { 217 adw_swipe_tracker_set_enabled(adwSwipeTracker, enabled); 218 } 219 220 /** 221 * Sets whether to reverse the swipe direction. 222 * 223 * Params: 224 * reversed = whether to reverse the swipe direction 225 * 226 * Since: 1.0 227 */ 228 public void setReversed(bool reversed) 229 { 230 adw_swipe_tracker_set_reversed(adwSwipeTracker, reversed); 231 } 232 233 /** 234 * Moves the current progress value by @delta. 235 * 236 * This can be used to adjust the current position if snap points move during 237 * the gesture. 238 * 239 * Params: 240 * delta = the position delta 241 * 242 * Since: 1.0 243 */ 244 public void shiftPosition(double delta) 245 { 246 adw_swipe_tracker_shift_position(adwSwipeTracker, delta); 247 } 248 249 /** 250 * This signal is emitted right before a swipe will be started, after the 251 * drag threshold has been passed. 252 * 253 * Since: 1.0 254 */ 255 gulong addOnBeginSwipe(void delegate(SwipeTracker) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 256 { 257 return Signals.connect(this, "begin-swipe", dlg, connectFlags ^ ConnectFlags.SWAPPED); 258 } 259 260 /** 261 * This signal is emitted as soon as the gesture has stopped. 262 * 263 * The user is expected to animate the deceleration from the current progress 264 * value to @to with an animation using @velocity as the initial velocity, 265 * provided in pixels per second. [class@SpringAnimation] is usually a good 266 * fit for this. 267 * 268 * Params: 269 * velocity = the velocity of the swipe 270 * to = the progress value to animate to 271 * 272 * Since: 1.0 273 */ 274 gulong addOnEndSwipe(void delegate(double, double, SwipeTracker) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 275 { 276 return Signals.connect(this, "end-swipe", dlg, connectFlags ^ ConnectFlags.SWAPPED); 277 } 278 279 /** 280 * This signal is emitted when a possible swipe is detected. 281 * 282 * The @direction value can be used to restrict the swipe to a certain 283 * direction. 284 * 285 * Params: 286 * direction = the direction of the swipe 287 * 288 * Since: 1.0 289 */ 290 gulong addOnPrepare(void delegate(AdwNavigationDirection, SwipeTracker) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 291 { 292 return Signals.connect(this, "prepare", dlg, connectFlags ^ ConnectFlags.SWAPPED); 293 } 294 295 /** 296 * This signal is emitted every time the progress value changes. 297 * 298 * Params: 299 * progress = the current animation progress value 300 * 301 * Since: 1.0 302 */ 303 gulong addOnUpdateSwipe(void delegate(double, SwipeTracker) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 304 { 305 return Signals.connect(this, "update-swipe", dlg, connectFlags ^ ConnectFlags.SWAPPED); 306 } 307 }